<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>embedme: src/FSMachine.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">FSMachine.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_f_s_machine_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef __FS_MACHINE_H__</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define __FS_MACHINE_H__</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; </div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_base_type_8h.html">BaseType.h</a>&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_thread_8h.html">Thread.h</a>&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;map&gt;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &lt;set&gt;</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="keyword">namespace </span>libemb{</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160; </div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="keyword">class </span>FSMachine;</div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="classlibemb_1_1_f_s_handler.html">   32</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlibemb_1_1_f_s_handler.html">FSHandler</a>{</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<a class="code" href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a>(<a class="code" href="classlibemb_1_1_f_s_handler.html">FSHandler</a>)</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <a class="code" href="classlibemb_1_1_f_s_handler.html">FSHandler</a>(){};</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    <span class="keyword">virtual</span> ~<a class="code" href="classlibemb_1_1_f_s_handler.html">FSHandler</a>(){};</div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="classlibemb_1_1_f_s_handler.html#a01d7804c779ba4cafeb19ba4070840d0">   42</a></span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classlibemb_1_1_f_s_handler.html#a01d7804c779ba4cafeb19ba4070840d0">handleState</a>()=0;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;};</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160; </div>
<div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="classlibemb_1_1_f_s_listener.html">   50</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlibemb_1_1_f_s_listener.html">FSListener</a>{</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">void</span> onStateChanged(<span class="keywordtype">int</span> stateID)=0;</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;};</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160; </div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="classlibemb_1_1_f_s_machine.html">   59</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlibemb_1_1_f_s_machine.html">FSMachine</a>:<span class="keyword">public</span> <a class="code" href="classlibemb_1_1_runnable.html">Runnable</a>{</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;<a class="code" href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a>(<a class="code" href="classlibemb_1_1_f_s_machine.html">FSMachine</a>)</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    <a class="code" href="classlibemb_1_1_f_s_machine.html">FSMachine</a>();</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keyword">virtual</span> ~<a class="code" href="classlibemb_1_1_f_s_machine.html">FSMachine</a>();</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="classlibemb_1_1_f_s_machine.html#a6e49950c3d324ad0810f8ed50519422b">startup</a>(<span class="keywordtype">int</span> stateID);</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_f_s_machine.html#aa40c187ddd739150c51fe38f18e718f9">quit</a>();</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="classlibemb_1_1_f_s_machine.html#a045e7fdf44fc39bea03a99cb9e67227a">registerState</a>(<span class="keywordtype">int</span> stateID,<a class="code" href="classlibemb_1_1_f_s_handler.html">FSHandler</a>&amp; stateHandler);</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_f_s_machine.html#a274aa38b674a12c7e6d1720b1b593df3">registerListener</a>(<a class="code" href="classlibemb_1_1_f_s_listener.html">FSListener</a>&amp; listener);</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <span class="keywordtype">void</span> run();</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    <a class="code" href="classlibemb_1_1_thread.html">Thread</a> m_thread;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keywordtype">int</span> m_currState{-1};</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    std::map&lt;int,FSHandler*&gt; m_stateHandlerMap;</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    std::set&lt;FSListener*&gt; m_stateListenerSet;</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;};</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160; </div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;}</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160; </div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclasslibemb_1_1_f_s_machine_html_aa40c187ddd739150c51fe38f18e718f9"><div class="ttname"><a href="classlibemb_1_1_f_s_machine.html#aa40c187ddd739150c51fe38f18e718f9">libemb::FSMachine::quit</a></div><div class="ttdeci">void quit()</div><div class="ttdoc">退出状态机</div><div class="ttdef"><b>Definition:</b> FSMachine.cpp:19</div></div>
<div class="ttc" id="aclasslibemb_1_1_f_s_handler_html_a01d7804c779ba4cafeb19ba4070840d0"><div class="ttname"><a href="classlibemb_1_1_f_s_handler.html#a01d7804c779ba4cafeb19ba4070840d0">libemb::FSHandler::handleState</a></div><div class="ttdeci">virtual int handleState()=0</div><div class="ttdoc">状态处理函数</div></div>
<div class="ttc" id="aclasslibemb_1_1_f_s_handler_html"><div class="ttname"><a href="classlibemb_1_1_f_s_handler.html">libemb::FSHandler</a></div><div class="ttdoc">状态处理器</div><div class="ttdef"><b>Definition:</b> FSMachine.h:32</div></div>
<div class="ttc" id="aclasslibemb_1_1_f_s_machine_html"><div class="ttname"><a href="classlibemb_1_1_f_s_machine.html">libemb::FSMachine</a></div><div class="ttdoc">状态机</div><div class="ttdef"><b>Definition:</b> FSMachine.h:59</div></div>
<div class="ttc" id="aclasslibemb_1_1_f_s_listener_html"><div class="ttname"><a href="classlibemb_1_1_f_s_listener.html">libemb::FSListener</a></div><div class="ttdoc">状态监听器</div><div class="ttdef"><b>Definition:</b> FSMachine.h:50</div></div>
<div class="ttc" id="aclasslibemb_1_1_thread_html"><div class="ttname"><a href="classlibemb_1_1_thread.html">libemb::Thread</a></div><div class="ttdef"><b>Definition:</b> Thread.h:56</div></div>
<div class="ttc" id="aclasslibemb_1_1_f_s_machine_html_a6e49950c3d324ad0810f8ed50519422b"><div class="ttname"><a href="classlibemb_1_1_f_s_machine.html#a6e49950c3d324ad0810f8ed50519422b">libemb::FSMachine::startup</a></div><div class="ttdeci">bool startup(int stateID)</div><div class="ttdoc">启动状态机</div><div class="ttdef"><b>Definition:</b> FSMachine.cpp:13</div></div>
<div class="ttc" id="a_base_type_8h_html"><div class="ttname"><a href="_base_type_8h.html">BaseType.h</a></div><div class="ttdoc">基础类型头文件</div></div>
<div class="ttc" id="aclasslibemb_1_1_f_s_machine_html_a274aa38b674a12c7e6d1720b1b593df3"><div class="ttname"><a href="classlibemb_1_1_f_s_machine.html#a274aa38b674a12c7e6d1720b1b593df3">libemb::FSMachine::registerListener</a></div><div class="ttdeci">void registerListener(FSListener &amp;listener)</div><div class="ttdoc">注册状态监听器</div><div class="ttdef"><b>Definition:</b> FSMachine.cpp:26</div></div>
<div class="ttc" id="a_thread_8h_html"><div class="ttname"><a href="_thread_8h.html">Thread.h</a></div><div class="ttdoc">线程</div></div>
<div class="ttc" id="aclasslibemb_1_1_runnable_html"><div class="ttname"><a href="classlibemb_1_1_runnable.html">libemb::Runnable</a></div><div class="ttdoc">线程运行体,子类必须重写run方法.</div><div class="ttdef"><b>Definition:</b> Thread.h:44</div></div>
<div class="ttc" id="a_base_type_8h_html_a57e803e49526dc5ba8c1915c68708ae0"><div class="ttname"><a href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a></div><div class="ttdeci">#define DECL_CLASSNAME(ClassName)</div><div class="ttdef"><b>Definition:</b> BaseType.h:176</div></div>
<div class="ttc" id="aclasslibemb_1_1_f_s_machine_html_a045e7fdf44fc39bea03a99cb9e67227a"><div class="ttname"><a href="classlibemb_1_1_f_s_machine.html#a045e7fdf44fc39bea03a99cb9e67227a">libemb::FSMachine::registerState</a></div><div class="ttdeci">bool registerState(int stateID, FSHandler &amp;stateHandler)</div><div class="ttdoc">注册状态处理器</div><div class="ttdef"><b>Definition:</b> FSMachine.cpp:31</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
